/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Table;

/**
 *
 * @author Boriz
 */

import Boundary.*;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

public class Smstabelmodel extends AbstractTableModel{
    private List<TU> tu = new ArrayList<TU>();

    public Smstabelmodel(List<TU> tu) {
        this.tu = tu;
    }

    public int getRowCount() {
        return this.tu.size();
    }

    public int getColumnCount() {
        return 5;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        TU t = tu.get(rowIndex);

        switch (columnIndex)
        {
            case 0: return t.getNis().getNIS();
            case 1: return t.getNama().getNama();
            case 2: if (t.getStatus().getKodekehadiran() == 1) {
                return "Masuk";
            }  if (t.getStatus().getKodekehadiran() == 2) {
                return "Ijin";
            }  if (t.getStatus().getKodekehadiran() == 3) {
                return "Sakit";
            } if (t.getStatus().getKodekehadiran() == 4) {
                return "Tidak Hadir";
            };
            case 3 : return t.getNamaortu().getNamaOrtu();
            case 4 : return t.getNohp().getNoTelp();
            default: return "";
        }
    }

    @Override
    public String getColumnName(int columnIndex){
        switch (columnIndex){
            case 0: return "NIS";
            case 1: return "Nama";
            case 2: return "Status";
            case 3: return "Nama Orang Tua";
            case 4: return "No HP";
            default: return "";
        }
    }
}
